//
//  ZSBottomBar.swift
//  ZSWeibo
//
//  Created by zsj1992 on 16/4/13.
//  Copyright © 2016年 ichange. All rights reserved.
//

import UIKit


//这个是底部的评论,赞等的那个工具条
class ZSBottomBar: UIView {


    //底部的bar也有一个模型,用于数据的设置
    var statusViewModel:ZSStatusViewModel?{
    
        didSet{

            
            setupBtn(statusViewModel!)
        
            
        }
    
    }
    
    //三个按钮上面有字的
    lazy var btnComment:UIButton = UIButton()

    lazy var btnRepost:UIButton = UIButton()
    
    lazy var btnLike:UIButton = UIButton()
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)

        setupUI()

        
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置UI的方法
    func setupUI(){
        
        addSubview(btnRepost)
        addSubview(btnComment)
        addSubview(btnLike)

        

        
        btnRepost.snp_makeConstraints { (make) -> Void in
        make.left.bottom.equalTo(self)
        
        }

        
        
        btnComment.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(btnRepost.snp_right)
            make.bottom.equalTo(btnRepost)
            make.width.equalTo(btnRepost)
        }
        
        
        
        btnLike.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(btnComment.snp_right)
            make.bottom.equalTo(btnComment)
            make.right.equalTo(self)
            make.width.equalTo(btnComment)
        }
        
        
        
        
        
        
        
        
        
    }
    
    
}

extension ZSBottomBar{

    //在这个方法中进行btn的文字和图片的设置
    func setupBtn(statusViewModel:ZSStatusViewModel){
        
        btnComment.setTitle(statusViewModel.commentTitle, forState: .Normal)
        btnComment.setImage(UIImage(named: "timeline_icon_comment"), forState: .Normal)
        btnComment.sizeToFit()
        btnComment.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btnComment.titleLabel?.font = UIFont.systemFontOfSize(14)
        
        btnRepost.setTitle(statusViewModel.repostTitle, forState: .Normal)
        btnRepost.setImage(UIImage(named: "timeline_icon_retweet"), forState: .Normal)
        btnRepost.sizeToFit()
        btnRepost.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btnRepost.titleLabel?.font = UIFont.systemFontOfSize(14)

        
        btnLike.setTitle(statusViewModel.likeTitle, forState: .Normal)
        btnLike.setImage(UIImage(named: "timeline_icon_like"), forState: .Normal)
        btnLike.sizeToFit()
        btnLike.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btnLike.titleLabel?.font = UIFont.systemFontOfSize(14)

        
    }


}









